#pragma once
#include <string>

class Product 
{
public:
    void SetPartA(const std::string& partA) 
    {
        _partA = partA; 
    }

    void SetPartB(const std::string& partB) 
    { 
        _partB = partB;
    }

    std::string GetDescription() const 
    {
        return "PartA: " + _partA + ", PartB: " + _partB;
    }
private:
    std::string _partA;
    std::string _partB;
};

class Builder 
{
public:
    virtual ~Builder() = default;
    virtual void BuildPartA() = 0;
    virtual void BuildPartB() = 0;
    virtual Product* GetResult() = 0;
};


class ConcreteBuilder : public Builder 
{
public:
    ConcreteBuilder() { _product = new Product(); }
    ~ConcreteBuilder() { delete _product; }
    void BuildPartA() override { _product->SetPartA("A部分"); }
    void BuildPartB() override { _product->SetPartB("B部分"); }
    Product* GetResult() override { return _product; }
private:
    Product* _product;
};

class Director 
{
public:
    void SetBuilder(Builder* builder) { _builder = builder; }
    Product* construct() 
    {
        _builder->BuildPartA();
        _builder->BuildPartB();
        return _builder->GetResult();
    }
private:
    Builder* _builder;
};